package com.waqu.common.utils.waqu;

/**
 * @Title WaquHostConfig.java
 * @Package com.waqu.common.utils.waqu
 * @author tangjunfeng
 * @date 2017年7月11日 下午7:53:02
 * @version V1.0
 */
public class WaquHostConfig {

	private static String defaultHostName = "www.feixun.tv";
	private static String picstatHostName = "picstat.feixun.tv";
	private static String imgHostName = "img.feixun.tv";
	private static String vssauthHostName = "vssauth.feixun.tv";
	private static String payHostName = "pay.feixun.tv";
	private static String staticHostName = "static.feixun.tv";

	public static String getDefaultHostName() {
		return defaultHostName;
	}

	public static void setDefaultHostName(String defaultHostName) {
		WaquHostConfig.defaultHostName = defaultHostName;
	}

	public static String getPicstatHostName() {
		return picstatHostName;
	}

	public static void setPicstatHostName(String picstatHostName) {
		WaquHostConfig.picstatHostName = picstatHostName;
	}

	public static String getImgHostName() {
		return imgHostName;
	}

	public static void setImgHostName(String imgHostName) {
		WaquHostConfig.imgHostName = imgHostName;
	}

	public static String getVssauthHostName() {
		return vssauthHostName;
	}

	public static void setVssauthHostName(String vssauthHostName) {
		WaquHostConfig.vssauthHostName = vssauthHostName;
	}

	public static String getPayHostName() {
		return payHostName;
	}

	public static void setPayHostName(String payHostName) {
		WaquHostConfig.payHostName = payHostName;
	}

	public static String getStaticHostName() {
		return staticHostName;
	}

	public static void setStaticHostName(String staticHostName) {
		WaquHostConfig.staticHostName = staticHostName;
	}

	public static String getDefaultHost() {
		return "http://" + defaultHostName;
	}

	public static String getPicstatHost() {
		return "http://" + picstatHostName;
	}

	public static String getImgHost() {
		return "http://" + imgHostName;
	}

	public static String getPayHost() {
		return "http://" + payHostName;
	}

	public static String getStaticHost() {
		return "http://" + staticHostName;
	}

	public static String getVssauthHost() {
		return "http://" + vssauthHostName;
	}

	public static String refreshDomain(STy sty, String path) {
		path = clipDomain(path);
		if (sty == STy.video)
			return getPicstatHost() + path;
		if (sty == STy.img)
			return getImgHost() + path;
		return path;
	}

	public static String clipDomain(String path) {
		if (path.startsWith("https://"))
			path = path.replace("https://", "http://");
		if (path.startsWith("http://")) {
			path = path.substring(7);
			path = path.substring(path.indexOf("/"), path.length());
		}
		return path.startsWith("/") ? path : "/" + path;
	}

}
